<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 不满足就不会渲染，惰性的，满足才开始渲染 -->
        <div v-if="type === 'A'">
            A
        </div>
        <div v-else-if="type === 'B'">
            B
        </div>
        <div v-else-if="type === 'C'">
            C
        </div>
        <div v-else>
            Not A/B/C
        </div>

        <!-- isShow = false : <div style="display: none;"> show </div> 不会不渲染-->
        <!-- 频繁切换用v-show -->
        <div v-show="isShow">
            show
        </div>

        <!-- v-if 优先级 比 v-for 高 -->

        <ul>
            <li v-for="(good, idx) of goods">
                <!-- in 可以用 of 替换 -->
                {{ idx }} --- {{ good.name }} --- {{ good.price }}
            </li>
        </ul>

        <ul>
            <li v-for="(value, key, idx) of myObject">
                <!-- in 可以用 of 替换 -->
                {{ idx + 1 }} --- {{ value }} --- {{ key }}
            </li>
        </ul>
    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
        const App = {
            data() {
                return {
                    type: 'A',
                    isShow: false,
                    goods: [
                        { name: '香皂', price: 3 },
                        { name: '毛巾', price: 5 },
                        { name: '盆', price: 10 },
                    ],
                    myObject: {
                        title: 'How to do lists in Vue',
                        author: 'Jane Doe',
                        publishedAt: '2016-04-10'
                    },
                    numbers: [1, 2, 3, 4, 5]
                }
            }
        }
        Vue.createApp(App).mount("#app")
    </script>
</body>

</html>